home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
SoundMaker 2003 (Professional Edition)
/
SoundMaker 2003 - Professional Edition.iso
/
midi tool
/
midioxse.exe
/
DATA.1
/
Breath2NRPN.js
< prev
next >
Wrap
Text File
|
1999-11-26
|
2KB
|
91 lines
// MIDIOX Test
// Copyright (c) 2000 by Jamie O'Connell
//
// This script is an example of doing JScript with MIDI-OX
// It converts each single Breath controller event into 4 NRPN messages, that
// control filters on Patches (XG instruments).
var mox;
var str, strWrk;
var n, ii, nInst;
var bGo;
var notesOn;
var baseChan;
// Create object
mox = WScript.CreateObject("MoxKart.MoxWire.1", "On_");
n = mox.NumberInstances;
if (n > 0)
{
nInst = 1;
if (mox.AttachInstance( nInst ) == 1)
WScript.Echo( "Attached Instance: " + nInst.toString() );
}
else if (mox.LaunchInstance() == 1)
{
nInst = 1;
if (mox.AttachInstance( nInst ) == 1)
WScript.Echo( "Launched and Attached Instance: " + nInst.toString() );
else
WScript.Echo( "Launched but could not Attach Instance: " + nInst.toString() );
}
else
WScript.Echo( "Launch MIDI-OX Failed" );
n = mox.NumberInstances;
// *** Try out our MIDI Input loop
notesOn = 0; // init
baseChan = 0; // init -- we expect channel 1
if (mox.IsAttached == 1)
{
mox.DivertMidiInput = 1;
mox.FireMidiInput = 1;
WScript.Echo( "Press OK to end MIDI translate Loop" );
mox.FireMidiInput = 0;
mox.DivertMidiInput = 0;
}
str = null;
strWrk = null;
mox = null;
// Exit Point
//------------------------------------------
function On_MidiInput( ts, stat, chan, dat1, dat2)
{
// We convert all breath control messages into 4 message NRPNS
var newStat, newChan;
var newDat1, newDat2;
// Change dat1 test: 'breath' (02) to 'modulation' (01) if you don't
// have a breath controller, but want to see how this works
if (stat == 0x0B0 && dat1 == 0x02)
{
newStat = stat + chan
mox.OutputMidiMsg( newStat, 0x63, 0x01 ); // NRPN MSB -- on XG (GS?): Filter cutoff
mox.OutputMidiMsg( newStat, 0x62, 0x20 ); // NRPN LSB
mox.OutputMidiMsg( newStat, 0x06, dat2 ); // DataEntry MSB (value of breath CC)
mox.OutputMidiMsg( newStat, 0x26, 0x00 ); // dataEntry LSB (0 in this case)
}
else // other message
{
newStat = stat + chan;
mox.OutputMidiMsg( newStat, dat1, dat2 );
}
}
//------------------------------------------
// connection point sink for SysEx
function On_SysExInput( strSysEx )
{
mox.SendSysExString( strSysEx );
}